package it.zqdszb.mvp.modelImp;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import it.zqdszb.entity.ChannelListBean;
import it.zqdszb.library.api.HttpPostService;
import it.zqdszb.library.api.entitys.BaseResult;
import it.zqdszb.library.basemvp.BaseModeImpl;
import it.zqdszb.library.retrofit.exception.ApiException;
import it.zqdszb.mvp.callback.OnChannelListCallBall;
import it.zqdszb.mvp.contract.ChannelListContract;

/**
 * Created by GH on 2018-05-14.
 */

public class ChannelListModelModelImp  extends BaseModeImpl implements ChannelListContract.ChannelListModel{
	OnChannelListCallBall callBack;

	@Override
	public void fetchData(int groupId,OnChannelListCallBall callBack) {
		this.callBack=callBack;
		Map<String, Object> params = new HashMap<>();
		params.put("groupId",String.valueOf(groupId));
		sendPost(HttpPostService.getChannellist, params, ChannelListBean.class, true, false, null);
	}

	@Override
	public void onNext(BaseResult result) {
		callBack.onSuccess((List<ChannelListBean>) result.getResult());
	}

	@Override
	public void onError(ApiException e, String mothead) {
		super.onError(e, mothead);
		callBack.onFailed(e);
	}
}
